package com.newx.common.core.enums;

import lombok.Getter;

/**
 * 订阅类型
 */
@Getter
public enum SubscriberTypeEnum {

    TWO_FOUR_HR_TICKER("实时数据订阅", "24hrTicker"),
    TRADE("交易数据订阅", "trade"),
    PING("心跳", "ping"),
    SECOND_TASK("期权结算", "secondTask"),
    KLINE("K线数据订阅", "kline");

    private final String chineseName;
    private final String value;

    SubscriberTypeEnum(String chineseName, String value) {
        this.chineseName = chineseName;
        this.value = value;
    }

    // 可以添加一些其他有用的方法，比如根据值获取对应的枚举实例
    public static SubscriberTypeEnum fromValue(String value) {
        for (SubscriberTypeEnum type : SubscriberTypeEnum.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }

    // 可以添加一个根据中文名称获取枚举实例的方法
    public static SubscriberTypeEnum fromChineseName(String chineseName) {
        for (SubscriberTypeEnum type : SubscriberTypeEnum.values()) {
            if (type.getChineseName().equals(chineseName)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid chineseName: " + chineseName);
    }
}
